package websocketgulu.demo.service;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import websocketgulu.demo.dao.DoctorMapper;

import java.util.HashMap;

/**
 * @Classname:DoctorService
 * @author :liuao
 * @date：2021/5/19
 */

@Service
public class DoctorService {
    @Autowired
    private DoctorMapper doctorMapper;
//    启动事务，插入用户
    @Transactional
    public void addDoctor(HashMap map){
        doctorMapper.addDC_info(map);
    }
//    根据phone的值判断用户是否已经存在
    public boolean DC_is_exist(HashMap map){
        return doctorMapper.DC_is_exist(map)!=null;
    }

    // 根据code的值查询邀请码是否有效
    public boolean code_is_exist( String code ){
        return doctorMapper.code_is_exist( code ) != null;
    }

    // 登录
    public boolean login(HashMap map){
        String password = (String) map.get("password");
        return password.equals( doctorMapper.DC_login( map ) );
    }
}
